package com.example.testp;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.Log;
import android.view.SurfaceHolder;
import javax.microedition.lcdui.*;   
import javax.microedition.lcdui.game.*;   

public class GameThread extends Thread {

	/**
	 * @param argsdsafsafcvzxcvcxv
	 */
	SurfaceHolder surfaceHolder;
	boolean run=true;
	String tag="GameView2";
	int i=1;
	Rect rec;
	
	public GameThread(SurfaceHolder sh,Rect rec){
		surfaceHolder=sh;
		this.rec=rec;
	}
	
	public void run(){
		Canvas c=null;
		
		while(run){
			try{
				synchronized(surfaceHolder){
					Rect rec=new Rect(this.rec);
					c=surfaceHolder.lockCanvas(rec);
					c.drawARGB(255, 255, 255, 255);
					c.drawText(""+(i++),this.rec.left+10,this.rec.top+10,new Paint());
					Thread.sleep(1000);
				}
			}catch(Exception e){
				e.printStackTrace();
				Log.v(tag,"error");
			}finally{
				if(c!=null){
					surfaceHolder.unlockCanvasAndPost(c);
				}
			}
		}
		
	}

}
